package com.ks.sgms.servlet;
import java.io.IOException;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.ks.sgms.dao.ScoreDao;
import com.ks.sgms.dao.StudentDao;
import com.ks.sgms.entity.Score;
import com.ks.sgms.entity.Student;

@WebServlet("/updateStudent")
public class UpdateStudentServlet extends HttpServlet{
	@Override
	protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
		req.setCharacterEncoding("UTF-8");
		Student s = new Student();
		s.student_id = req.getParameter("student_id_up");
		s.student_name = req.getParameter("student_name_up");
		s.class_id = req.getParameter("class_id_up");
		s.sex =Integer.parseInt(req.getParameter("sex_up"));
		s.birthString =req.getParameter("birthString_up");
		boolean suc = new StudentDao().updateStudent(s);
		if(suc) 
			req.getRequestDispatcher("student.jsp").forward(req, resp);
		else
			req.getRequestDispatcher("student-update.jsp").forward(req, resp);	
	}
}
